<?php
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;

class DefaultDb_Repositories_PointRepository extends EntityRepository
{
    public function getPointByNameOrAddress($stringSearch,$state)
    {
        $em = $this->getEntityManager();
        $dql = 'SELECT p
                FROM DefaultDb_Entities_Point p
                WHERE (p.name LIKE :search OR
                p.address LIKE :search )
                AND p.status = :status
                AND p.state = :state';
        $query = $em->createQuery($dql);
        $query->setParameter('search', '%' . $stringSearch . '%');
        $query->setParameter('status', DefaultDb_Entities_Point::STATUS_NORMAL );
        $query->setParameter('state', $state );
        $points = $query->getResult();
        return $points;
    }
}